<%@ tag body-content="scriptless" dynamic-attributes="dynattrs"
        pageEncoding="windows-1252" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


<%@ attribute name="testsetResult" required="true" rtexprvalue="true" type="org.testfire.model.TestsetResultType" %>

<c:catch var="ex">
    <tr style="border-width:2px;border-color:black">
        <td>${testsetResult.wasSuccessful}</td>
        <td>${testsetResult.runDate}</td>
        <td>${testsetResult.runCount}</td>
        <td>${testsetResult.failureCount}</td>
        <td>${testsetResult.ignoreCount}</td>
        <td>${testsetResult.timeElapsed}</td>
        <td>${testsetResult.messages}</td>
    </tr>
</c:catch>
<c:if test="${!empty ex}">
    <!-- ${ex} -->
</c:if>

<c:forEach items="${testsetResult.testResults}" var="test">
    <tr>
        <td><h4 style="text-align:center">${test.owningTest.name}</h4></td>
        <td colspan="6">

            <table style="width:100%;margin-left:0%;" border="2" cellpadding="2">
                <thead>
                    <tr>
                        <th>Result</th>
                        <th>Description</th>
                        <th>Time Elapsed</th>
                        <th>Failure Info</th>
                    </tr>
                </thead>
                <tr>
                    <td>${test.result}</td>
                    <td>${empty test.description ? '&nbsp;' : test.description}</td>
                    <td>${test.runTime}</td>
                    <c:choose>
                        <c:when test="${!empty test.failure}">
                            <script type="text/javascript">
                                function showFailureInfo( linkObj )
                                {
                                    var popupObj = window.open();
                                    var popupBodyObj = popupObj.document.body;
                                    popupBodyObj.style.border = "1px black solid";
                                    var src = "<div<h4>Message:</h4><p><pre>${test.failure.message}</pre></p>";
                                    src += "</div><div><h4>Trace: </h4><p><pre>${test.failure.jsSafeTrace}</pre></p></div>";
                                    popupBodyObj.innerHTML = src;
                                }

                            </script>
                            <td><a href="javascript:void(0);" onclick="showFailureInfo(this)">Failure Info</a></td>
                        </c:when>
                        <c:otherwise>&nbsp;</c:otherwise>
                    </c:choose>

                </tr>
            </table>
        </td>
    </tr>

</c:forEach>